//
//  MSCollectDataSource.m
//  MSJD
//
//  Created by 箭军刘 on 2018/10/19.
//  Copyright © 2018年 xiangbo. All rights reserved.
//

#import "MSCollectDataSource.h"

@implementation MSCollectDataSource

+ (void)queryCollectDataWithKind:(NSInteger)kind
                            page:(NSInteger)page
                        pageSize:(NSInteger)pageSize
                         success:(void (^)(NSDictionary *responseInfo))success
                         failure:(void (^)(NSError *error))failure {
    NSString *requestUrl = @"v1/favor/list";
    NSInteger uid = [[UserAccesser loadAccount].userId integerValue];
    CGFloat lon = [UserAccesser longitudeValue];
    CGFloat lat = [UserAccesser latitudeValue];
    NSDictionary *param = @{@"page":@(page), @"size":@(pageSize), @"uid":@(uid), @"lon":@(lon), @"lat":@(lat), @"kid":@(kind)};
    // FIXME:
    [MSNetworkAPI GET:requestUrl domain:API_TOPHRMING parameters:param success:^(id responseObject) {
        NSDictionary *responseInfo = (NSDictionary *)responseObject;
        if (!responseObject || !responseInfo[@"data"]) {
            if (failure) {
                failure(nil);
            }
            return ;
        }
        if (success) {
            success(responseInfo[@"data"]);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
//    [MSRequestClient GET:requestUrl parameters:param responseClassType:NSDictionary.class success:^(id responseObject) {
//        if (success) {
//            success((NSDictionary *)responseObject);
//        }
//    } failure:^(NSError *error) {
//        if (failure) {
//            failure(error);
//        }
//    }];
}

+ (void)removeCollectDataWithHotelId:(NSInteger)hotelId
                             success:(void (^)(NSDictionary *responseInfo))success
                             failure:(void (^)(NSError *error))failure {
    NSString *requestUrl = @"v1/favor/remove";
    NSInteger uid = [[UserAccesser loadAccount].userId integerValue];
    NSDictionary *param = @{@"tid":@(hotelId), @"uid":@(uid)};
    [MSNetworkAPI POST:requestUrl domain:API_TOPHRMING parameters:param isJsonData:NO success:^(id responseObject) {
        if (success) {
            success((NSDictionary *)responseObject);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


@end
